package Eyjafjalla.effect;

import Eyjafjalla.patch.MelodyPatch;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Interpolation;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.vfx.AbstractGameEffect;

public class MelodyNoteFlashEffect extends AbstractGameEffect {
    private float x;
    private float y;
    private Texture img;
    private static final int W = 32;
    private float scale;

    public MelodyNoteFlashEffect(MelodyPatch.MelodyNote note) {
        this.scale = Settings.scale;
        this.x = note.noteHb.cX;
        this.y = note.noteHb.cY;

        this.img = note.image;

        this.duration = 0.7F;
        this.startingDuration = 0.7F;
        this.color = Color.WHITE.cpy();
        this.renderBehind = false;
    }

    public void update() {
        super.update();
        this.scale = Interpolation.exp5In.apply(Settings.scale, Settings.scale * 0.3F, this.duration / this.startingDuration);
    }

    public void render(SpriteBatch sb) {
        sb.setBlendFunction(770, 1);
        sb.setColor(this.color);
        if (this.img != null) {
            sb.draw(this.img, this.x - 16.0F, this.y - 16.0F, 16.0F, 16.0F, 32.0F, 32.0F, this.scale * 6.0F, this.scale * 6.0F, 0.0F, 0, 0, 64, 64, false, false);
            sb.draw(this.img, this.x - 16.0F, this.y - 16.0F, 16.0F, 16.0F, 32.0F, 32.0F, this.scale * 5.0F, this.scale * 5.0F, 0.0F, 0, 0, 64, 64, false, false);
            sb.draw(this.img, this.x - 16.0F, this.y - 16.0F, 16.0F, 16.0F, 32.0F, 32.0F, this.scale * 4.0F, this.scale * 4.0F, 0.0F, 0, 0, 64, 64, false, false);
            sb.draw(this.img, this.x - 16.0F, this.y - 16.0F, 16.0F, 16.0F, 32.0F, 32.0F, this.scale * 3.5F, this.scale * 3.5F, 0.0F, 0, 0, 64, 64, false, false);
        }

        sb.setBlendFunction(770, 771);
    }

    public void dispose() {
    }
}

